package com.qcby.controller;

import com.qcby.entity.Exam;
import com.qcby.entity.LessonPlan;
import com.qcby.entity.Result;
import com.qcby.service.ExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/exam")
@Api(tags = "考试接口")
public class ExamController {
    @Autowired
    private ExamService examService;
    @PostMapping("/getExam")
    @ApiModelProperty("获取考试信息")

    public Result getExam(Exam exam)
    {
        return Result.success(examService.getExam(exam));
    }
    @PostMapping("/addExam")
    @ApiModelProperty("添加考试信息")
    public Result addExam(@RequestBody Exam exam) throws IOException {
        System.out.println(exam);
        return Result.success(examService.addExam(exam));
    }
    @ApiModelProperty("通过教案生成考试")
    @PostMapping("/addExamByLessoinPlan")
    public Result addExamByLessoinPlan(LessonPlan plan) throws IOException {
        System.out.println(plan);
        return Result.success(examService.addExamByLessionPlan(plan));
    }
    @PostMapping("/GetExamById")
    @ApiModelProperty("通过id获取考试信息")
    public Result getExamById(Integer id){
        return Result.success(examService.getExamById(id));
    }
    @PostMapping("/updateExambyId")
    @ApiModelProperty("通过id修改考试信息")
    public Result updateExambyId(Integer id){
        examService.updateExambyId(id);
        return Result.success();
    }
    @PostMapping("/GetExamByName")
    @ApiModelProperty("通过名称获取考试信息")
    public Result getExamByName(Exam exam){
        System.out.println(exam);
        Result examByName = examService.getExamByName(exam);
        return examByName;
    }
    @PostMapping("/deleteExam")
    @ApiModelProperty("通过名称删除考试信息")
    public Result deleteExam(String name){
        examService.deleteExam(name);
        return Result.success();
    }
}
